package com.zhumr.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhumr.model.ActorInfo;
import com.zhumr.service.IActorInfoService;

@Controller
@RequestMapping("/webActor")
public class ActorController {

	@Autowired
	private IActorInfoService actorService;

	@RequestMapping("/getAllActor")
	@ResponseBody
	public Map<String, Object> getAllActor(HttpServletRequest request, String min, String max, String Sex,
			String Area, String likeString) {

		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("min", min);
		paramMap.put("max", max);
		paramMap.put("Sex", Sex);
		paramMap.put("Area", Area);
		paramMap.put("likeString", likeString);

		List<ActorInfo> actorList = actorService.getAllActor(paramMap);

		Map<String, Object> result = new HashMap<String, Object>();
		if (actorList != null) {
			result.put("code", "0");
			result.put("crew", actorList);
		} else {
			result.put("code", "1");
			result.put("crew", null);
		}
		return result;
	}

	/**
	 * 剧组详情
	 * 
	 * @param request
	 * @param id
	 * @return
	 */
	@RequestMapping("/getActorById")
	@ResponseBody
	public Map<String, Object> getActorByid(HttpServletRequest request, int id) {

		ActorInfo actor = actorService.getActorById(id);

		Map<String, Object> result = new HashMap<String, Object>();
		if (actor != null) {
			result.put("code", "0");
			result.put("crew", actor);
		} else {
			result.put("code", "1");
			result.put("crew", null);
		}
		return result;
	}

}
